home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / istruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.5 KB  |  93 lines

  1. /* Copyright (C) 1994, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: istruct.h,v 1.2 2000/09/19 19:00:46 lpd Exp $ */
  20. /* Interpreter-level extension of gsstruct.h */
  21.  
  22. #ifndef istruct_INCLUDED
  23. #  define istruct_INCLUDED
  24.  
  25. #include "gsstruct.h"
  26.  
  27. /* ================ Refs ================ */
  28.  
  29. /*
  30.  * Define the pointer type for refs.  Note that if a structure contains refs,
  31.  * both its clear_marks and its reloc_ptrs procedure must unmark them,
  32.  * since the GC will never see the refs during the unmarking sweep.
  33.  */
  34. extern const gs_ptr_procs_t ptr_ref_procs;
  35. #define ptr_ref_type (&ptr_ref_procs)
  36.  
  37. /* The structure type descriptor for (blocks of) refs. */
  38. /* This is defined in igc.c and exported for isave.c. */
  39. extern_st(st_refs);
  40.  
  41. /*
  42.  * Extend the GC procedure vector to include refs.
  43.  */
  44. #define refs_proc_reloc(proc)\
  45.   void proc(P3(ref_packed *from, ref_packed *to, gc_state_t *gcst))
  46. typedef struct gc_procs_with_refs_s {
  47.     gc_procs_common;
  48.     /* Relocate a pointer to a ref[_packed]. */
  49.     ptr_proc_reloc((*reloc_ref_ptr), ref_packed);
  50.     /* Relocate a block of ref[_packed]s. */
  51.     refs_proc_reloc((*reloc_refs));
  52. } gc_procs_with_refs_t;
  53.  
  54. #undef gc_proc
  55. #define gc_proc(gcst, proc) ((*(const gc_procs_with_refs_t **)(gcst))->proc)
  56.  
  57. /*
  58.  * Define enumeration and relocation macros analogous to those for
  59.  * structures and strings.  (We should go back and change the names of
  60.  * those macros to be consistent which these, which are better, but it's
  61.  * not worth the trouble.)
  62.  */
  63. #define ENUM_RETURN_REF(rptr)\
  64.   return (pep->ptr = (const void *)(rptr), ptr_ref_type)
  65. #define ENUM_RETURN_REF_MEMBER(typ, memb)\
  66.   ENUM_RETURN_REF(&((typ *)vptr)->memb)
  67. #define RELOC_REF_PTR_VAR(ptrvar)\
  68.   ptrvar = (*gc_proc(gcst, reloc_ref_ptr))((const void *)(ptrvar), gcst)
  69. #define RELOC_REF_PTR_MEMBER(typ, memb)\
  70.   RELOC_REF_PTR_VAR(((typ *)vptr)->memb)
  71. #define RELOC_REFS(from, upto)\
  72.   (*gc_proc(gcst, reloc_refs))((ref_packed *)(from), (ref_packed *)(upto), gcst)
  73. #define RELOC_REF_VAR(refvar)\
  74.   RELOC_REFS(&(refvar), &(refvar) + 1)
  75.  
  76. /*
  77.  * Define an object allocated as a struct, but actually containing refs.
  78.  * Such objects are useful as the client_data of library structures
  79.  * (currently only gstates and fonts).
  80.  */
  81. struct_proc_clear_marks(ref_struct_clear_marks);
  82. struct_proc_enum_ptrs(ref_struct_enum_ptrs);
  83. struct_proc_reloc_ptrs(ref_struct_reloc_ptrs);
  84. #define gs__st_ref_struct(scope_st, stname, stype, sname)\
  85.   gs__st_complex_only(scope_st, stname, stype, sname, ref_struct_clear_marks,\
  86.     ref_struct_enum_ptrs, ref_struct_reloc_ptrs, 0)
  87. #define gs_public_st_ref_struct(stname, stype, sname)\
  88.   gs__st_ref_struct(public_st, stname, stype, sname)
  89. #define gs_private_st_ref_struct(stname, stype, sname)\
  90.   gs__st_ref_struct(private_st, stname, stype, sname)
  91.  
  92. #endif /* istruct_INCLUDED */
  93.